home *** CD-ROM | disk | FTP | other *** search
- COMAL AND YOU - For Beginners Only
- by David Stidolph
-
- WHY LEARN TO PROGRAM?
-
- The many commercial computer programs
- available today are more than
- sufficient for most people's needs.
- If word processors, spread sheets,
- and data base managers are all your
- computer is used for, learning to
- program would be a waste of time.
-
- For some, however, a goal is being
- able to learn something new...
- something that can control that
- mysterious box called a computer.
- There's nothing like the feeling of
- accomplishment when you type in your
- first working program. Also,
- familiarity with computers and
- programming helps ease the sense of
- helplessness most people get when
- dealing with computers. (How did you
- feel the first time you got a
- computerized bill?) This article is
- for people who have made the decision
- to not only learn about computers,
- but to learn programming as well.
-
- WHAT IS A COMPUTER LANGUAGE?
-
- Computers work with a language of
- zeros and ones called machine code.
- This is as difficult to use as it
- sounds, and few programmers now work
- directly in machine code. They choose
- instead to use computer "languages".
- These range from low level languages
- like assembly code, where the words
- merely represent individual machine
- code instructions, to high level
- languages which look more like
- English. Compare the following two
- programs:
-
- ASSEMBLY CODE
- -------------
-
- * = START
- LDY #$00
- LP LDA STRING,Y
- BEQ ENDLP
- JSR OUTPUT
- INY
- BNE LP
- BEQ ENDLP
- .BYT 'This is a string',13,0
- ENDLP <...> ; rest of program code
-
- COMAL
- -----
-
- PRINT "This is a string"
-
- As you can see, the statement written
- in COMAL is shorter and much more
- readable. Although the computer will
- seem to understand COMAL statements
- and programs, the computer itself
- only understands machine code. COMAL,
- the language, is a machine code
- program. It must be loaded into your
- computer before you can write, edit,
- or run COMAL programs. Think of the
- language as a translater between you
- and the computer. This means you
- don't have to learn machine code -
- you only have to make sure that COMAL
- is in the machine before you can run
- your COMAL programs.
-
- WHY LEARN COMAL?
-
- Since BASIC comes with most personal
- computers today, many people think
- that it is the best computer language
- to learn. Not so. BASIC is
- implemented on so many computers
- because it is the easiest language to
- write. It has the fewest commands,
- and NO definite standard to follow.
- This means that a BASIC program
- written on one computer may NOT run
- on another computer. BASIC does,
- however, have one good feature; it
- will let you type in a short program
- and see it execute as soon as you
- type the word RUN. Text editors or
- elaborate compiler commands are not
- necessary (Most other high level
- languages like Pascal, FORTRAN and
- COBOL require them). This makes BASIC
- seem like a easy-to-learn language
- for everyone.
-
- COMAL started with this idea of
- interactive work with the programmer,
- then added to it. COMAL has
- structures such as WHILE, REPEAT, and
- FOR loops, multi-line IF-THEN-ELSE
- statements, a CASE statement
- (similiar to a multiple choice
- question), and named PROCedures and
- FUNCtions complete with parameters.
- These structures are similiar those
- in "professional" languages like
- Pascal. COMAL also has the turtle
- graphics made famous by Logo. COMAL
- is now the language taught in the
- schools of 5 European countries.
- COMAL is easier to learn than BASIC,
- and teaches the idea of structured
- programing necessary with modern
- computer languages.
-
- HOW DO I GET COMAL?
-
- Congratulations, COMAL is included on
- this Ahoy disk. To use COMAL, follow
- these steps:
-
- 1. Type LOAD ":*",8
- Type RUN
- This puts you in Ahoy's main menu.
- 2. Choose the "COMAL 64 BOOT" option.
- This will give you COMAL's
- introductory screen. You will be
- given some COMAL information and
- then asked if you want error
- messages in memory. Hit the return
- key for the default answer of yes.
- 3. After a short wait, you will be
- put in a COMAL program displaying
- another menu. This will allow you
- to run the COMAL programs on this
- disk, or to read articles such as
- the one you are reading now. If
- you want to enter the COMAL editor
- to write your own programs, simply
- enter the "QUIT THIS MENU" option.
- 4. If you are already in COMAL, but
- want to re-enter the menu from
- step 3, all you need to do is type
- in:
-
- CHAIN "hi"
-
- assuming the Ahoy disk is in the
- disk drive.
-
- NOTE: COMAL and the COMAL programs on
- this disk are copyrighted, but we
- give you permission to give copies
- away. This permission does not apply
- to the BASIC programs from Ahoy.
-
- WHAT DO I DO WITH COMAL?
-
- Since COMAL is on this Ahoy disk, you
- can learn to write readable programs.
- One way to learn is to first look at
- other peoples' work. I will detail
- certain commands now so that you can
- do just that. The commands will be
- listed in UPPERCASE, but type them in
- with unshifted letters.
-
- CAT
-
- This command will show you what files
- are on the disk in the disk drive.
- The disk drive sends the disk
- DIRECTORY to the computer, and COMAL
- prints it on the screen. The actual
- listing shows more than just file
- names. It shows how big they are,
- their names, and the file type. Each
- entry in the directory is called a
- file, and there are four types of
- files - PRG (program), SEQ
- (sequential - data files), REL
- (random - also data files), and USR
- (special files). Unlike the BASIC
- commands:
-
- LOAD "$",8
- LIST
-
- COMAL will not erase the program in
- memory while showing a directory of a
- disk. You can slow the scrolling
- lines by holding down the CTRL key on
- the upper left hand side of the
- keyboard, or stop it by pressing the
- RUN/STOP key (right below the CTRL
- key). If you happen to have a dual
- drive (a two drive unit) you can add
- a '0' or a '1' after the command:
-
- cat 0 (This is for drive 0)
- cat 1 (This is for drive 1)
-
- LOAD
-
- Once you know what is on a disk, you
- can load COMAL programs into memory
- with this command. It is similar to
- the BASIC LOAD command, except you no
- longer need to type the comma 8. The
- following is an example of loading a
- program called "filename" from the
- disk drive:
-
- load "filename"
-
- Only PRG type files can be loaded. Be
- careful, because other languages,
- like BASIC, also store their programs
- as PRG files. COMAL 0.14 will attempt
- to load any PRG type file you ask it
- to. If you are not sure whether or
- not a program was written in COMAL
- 0.14, load the program and LIST it.
- Only COMAL 0.14 programs can be
- listed, any other type of program
- (BASIC, COMAL 2.0, etc) will not
- list. DO NOT RUN PROGRAMS WHICH WON'T
- LIST. If you do, COMAL will become
- confused and stop functioning. The
- only thing to do after this has
- happened is to turn the computer off
- and reload COMAL.
-
- LIST
-
- Once a COMAL program is in memory,
- you will want to be able to see it.
- The command LIST will do just that,
- it will list the program to the
- screen. The first thing you will
- notice is you will want to slow or
- stop the listing (so you can study
- it). Just as with the catalog
- command, you can use the CTRL key to
- slow the listing, or the RUN/STOP key
- to stop the listing. When LISTing a
- PROGRAM, the space bar will pause the
- listing.
-
- You will notice that each line has a
- number in front of it. COMAL uses
- them to keep track of the order of
- the program lines. The order goes
- from low (1) to high (9999). You can
- use any line number between.
-
- The LIST command can also be used to
- show just part of a program. The
- following are some examples to do
- just that:
-
- list (all lines)
- list 100-500 (from line 100 to 500)
- list 100- (from line 100 to end)
- list -500 (from beginning to 500)
-
- RUN
-
- When the program you want has been
- loaded into memory, you start the
- program with the command RUN. The
- computer does a quick scan of the
- program to make sure it seems
- correct, and starts executing with
- the first line of the program. If an
- error occurs while the program is
- running, the program will stop
- executing. COMAL will print what the
- problem is and the line number it
- occured on.
-
- MAKING ERRORS
-
- There is a very good chance that you
- will make typing errors while trying
- these commands. COMAL checks each
- line you type for errors, and if it
- cannot understand what you typed, it
- will stop and give you an error
- message. It might go out to the disk
- drive and get the error message, or
- it might just print the message
- itself (that depends on your choice
- to have error messages in memory or
- not). If you get an error, COMAL will
- put the cursor on the part of the
- line it is having trouble with so
- DON'T PANIC. Just make the correction
- and press the RETURN key again.
-
- STATUS
-
- If the red light on the disk drive
- starts blinking on and off while
- COMAL just sits there waiting for you
- to type something, try typing in the
- STATUS command. This will print disk
- error message to the screen. Check
- your disk drive manual for more
- information if necessary.
-